@echo off
echo =============================================
echo 手动下载Android依赖脚本
echo =============================================

echo 创建本地libs目录...
if not exist "app\libs" mkdir "app\libs"

echo.
echo 正在下载Room相关依赖...

echo [1/6] 下载androidx.sqlite:sqlite:2.4.0...
powershell -Command "try { Invoke-WebRequest -Uri 'https://maven.aliyun.com/repository/google/androidx/sqlite/sqlite/2.4.0/sqlite-2.4.0.aar' -OutFile 'app\libs\sqlite-2.4.0.aar' -TimeoutSec 30; Write-Host '√ 下载成功' } catch { Write-Host '× 阿里云下载失败，尝试华为云...' }"

if not exist "app\libs\sqlite-2.4.0.aar" (
    powershell -Command "try { Invoke-WebRequest -Uri 'https://repo.huaweicloud.com/repository/maven/androidx/sqlite/sqlite/2.4.0/sqlite-2.4.0.aar' -OutFile 'app\libs\sqlite-2.4.0.aar' -TimeoutSec 30; Write-Host '√ 华为云下载成功' } catch { Write-Host '× 华为云也失败' }"
)

echo [2/6] 下载androidx.room:room-common:2.6.1...
powershell -Command "try { Invoke-WebRequest -Uri 'https://maven.aliyun.com/repository/google/androidx/room/room-common/2.6.1/room-common-2.6.1.jar' -OutFile 'app\libs\room-common-2.6.1.jar' -TimeoutSec 30; Write-Host '√ 下载成功' } catch { Write-Host '× 阿里云下载失败，尝试华为云...' }"

if not exist "app\libs\room-common-2.6.1.jar" (
    powershell -Command "try { Invoke-WebRequest -Uri 'https://repo.huaweicloud.com/repository/maven/androidx/room/room-common/2.6.1/room-common-2.6.1.jar' -OutFile 'app\libs\room-common-2.6.1.jar' -TimeoutSec 30; Write-Host '√ 华为云下载成功' } catch { Write-Host '× 华为云也失败' }"
)

echo [3/6] 下载androidx.room:room-runtime:2.6.1...
powershell -Command "try { Invoke-WebRequest -Uri 'https://maven.aliyun.com/repository/google/androidx/room/room-runtime/2.6.1/room-runtime-2.6.1.aar' -OutFile 'app\libs\room-runtime-2.6.1.aar' -TimeoutSec 30; Write-Host '√ 下载成功' } catch { Write-Host '× 下载失败' }"

echo [4/6] 下载androidx.room:room-compiler:2.6.1...
powershell -Command "try { Invoke-WebRequest -Uri 'https://maven.aliyun.com/repository/google/androidx/room/room-compiler/2.6.1/room-compiler-2.6.1.jar' -OutFile 'app\libs\room-compiler-2.6.1.jar' -TimeoutSec 30; Write-Host '√ 下载成功' } catch { Write-Host '× 下载失败' }"

echo [5/6] 下载androidx.sqlite:sqlite-framework:2.4.0...
powershell -Command "try { Invoke-WebRequest -Uri 'https://maven.aliyun.com/repository/google/androidx/sqlite/sqlite-framework/2.4.0/sqlite-framework-2.4.0.aar' -OutFile 'app\libs\sqlite-framework-2.4.0.aar' -TimeoutSec 30; Write-Host '√ 下载成功' } catch { Write-Host '× 下载失败' }"

echo [6/6] 下载androidx.annotation:annotation:1.8.2...
powershell -Command "try { Invoke-WebRequest -Uri 'https://maven.aliyun.com/repository/google/androidx/annotation/annotation/1.8.2/annotation-1.8.2.jar' -OutFile 'app\libs\annotation-1.8.2.jar' -TimeoutSec 30; Write-Host '√ 下载成功' } catch { Write-Host '× 下载失败' }"

echo.
echo =============================================
echo 依赖下载完成！检查结果：
echo =============================================
dir "app\libs" /b

echo.
echo 如果有下载失败的文件，请手动从以下地址下载：
echo 1. https://maven.aliyun.com/repository/google/
echo 2. https://repo.huaweicloud.com/repository/maven/
echo 3. https://mirrors.cloud.tencent.com/nexus/repository/maven-public/
echo.
pause
